package com.example.mapper;

import com.example.POJO.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Insert("INSERT INTO orderdetail (user_id, product_id, time, status, count) VALUES (#{user_id}, #{product_id}, #{time}, #{status}, #{count})")
    void insertOrder(Order order);

    @Select("select * from orderdetail where user_id=#{user_id} and status=1")
    List<Order> getOrderByUserId(Integer user_id);

    @Update("update orderdetail set status=0 where id=#{orderId}")
    void setSubmitted(Integer orderId);

    @Select("select * from orderdetail where user_id=#{user_id} and status=0")
    List<Order> getSubmittedOrderByUserId(Integer userId);
}
